private static class ApplicationListenerMethodTransactionalAdapter.TransactionSynchronizationEventAdapter extends TransactionSynchronizationAdapter
Modifier and Type | Field and Description |
---|---|
private ApplicationEvent |
event |
private ApplicationListenerMethodAdapter |
listener |
private TransactionPhase |
phase |
STATUS_COMMITTED, STATUS_ROLLED_BACK, STATUS_UNKNOWN
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
Constructor and Description |
---|
TransactionSynchronizationEventAdapter(ApplicationListenerMethodAdapter listener,
ApplicationEvent event,
TransactionPhase phase) |
Modifier and Type | Method and Description |
---|---|
void |
afterCompletion(int status)
Invoked after transaction commit/rollback.
|
void |
beforeCommit(boolean readOnly)
Invoked before transaction commit (before "beforeCompletion").
|
int |
getOrder()
Get the order value of this object.
|
protected void |
processEvent() |
afterCommit, beforeCompletion, flush, resume, suspend
private final ApplicationListenerMethodAdapter listener
private final ApplicationEvent event
private final TransactionPhase phase
public TransactionSynchronizationEventAdapter(ApplicationListenerMethodAdapter listener, ApplicationEvent event, TransactionPhase phase)
public int getOrder()
Ordered
Higher values are interpreted as lower priority. As a consequence,
the object with the lowest value has the highest priority (somewhat
analogous to Servlet load-on-startup
values).
Same order values will result in arbitrary sort positions for the affected objects.
getOrder
in interface Ordered
getOrder
in class TransactionSynchronizationAdapter
Ordered.HIGHEST_PRECEDENCE
,
Ordered.LOWEST_PRECEDENCE
public void beforeCommit(boolean readOnly)
TransactionSynchronization
This callback does not mean that the transaction will actually be committed. A rollback decision can still occur after this method has been called. This callback is rather meant to perform work that's only relevant if a commit still has a chance to happen, such as flushing SQL statements to the database.
Note that exceptions will get propagated to the commit caller and cause a rollback of the transaction.
beforeCommit
in interface TransactionSynchronization
beforeCommit
in class TransactionSynchronizationAdapter
readOnly
- whether the transaction is defined as read-only transactionTransactionSynchronization.beforeCompletion()
public void afterCompletion(int status)
TransactionSynchronization
NOTE: The transaction will have been committed or rolled back already,
but the transactional resources might still be active and accessible. As a
consequence, any data access code triggered at this point will still "participate"
in the original transaction, allowing to perform some cleanup (with no commit
following anymore!), unless it explicitly declares that it needs to run in a
separate transaction. Hence: Use PROPAGATION_REQUIRES_NEW
for any transactional operation that is called from here.
afterCompletion
in interface TransactionSynchronization
afterCompletion
in class TransactionSynchronizationAdapter
status
- completion status according to the STATUS_*
constantsTransactionSynchronization.STATUS_COMMITTED
,
TransactionSynchronization.STATUS_ROLLED_BACK
,
TransactionSynchronization.STATUS_UNKNOWN
,
TransactionSynchronization.beforeCompletion()
protected void processEvent()